Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: selfish mining #832

Closed
wants to merge 2 commits into from
Closed

Conversation

Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Sep 25, 2023

neo-project/neo#2918

Prevents:

  • Primary starts consensus early.
  • Primary starts consensus early but with a future timestamp.

@Jim8y Jim8y changed the title fix selfish mining fix: selfish mining Sep 25, 2023
Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Liaojinghui ,what exactly are you trying to solve and when it happens?

I see the code and saw some blockIndex and 10000 as a value of the if. Why using block index?

@Jim8y
Copy link
Contributor Author

Jim8y commented Sep 25, 2023

The problem here is that malicious nodes can start the consensus early when they become the primary, speeding up the consensus and thus generating more blocks and mining more GAS. We did not check a thing that is similar to mining difficulty. As v17 has mentioned here neo-project/neo#2918, this is not an emergency fix, it is totally OK, it you think consensus nodes should be allowed to speed up the consensus maliciously.

I use 10000 just because i need a time window to konw what is the average block time in the past 10000 blocks, if they are shoter than the default consensus time, then the current consensus round would wait longer to slow down the consensus.

Copy link
Member

@shargon shargon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a new method IsValidTimestamp(previous, current) with UT?

@Jim8y
Copy link
Contributor Author

Jim8y commented Sep 26, 2023

Create a new method IsValidTimestamp(previous, current) with UT?

would be challenging to have 10000 blocks UT, LOL, lets find out.

@cschuchardt88
Copy link
Member

One way, is to use NeoSystem in memory, than you could sleep thread until height is 10k. Should download on network and should be quick.

@Jim8y
Copy link
Contributor Author

Jim8y commented Sep 26, 2023

Kinda fun when i set it to 10000, not anymore.

@Jim8y Jim8y closed this Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants